package model.player;

import java.util.List;

import model.map.GameTile;
import model.mapping.PlayableMapping;
import model.playable.structure.Structure;
import model.playable.unit.Worker;

/**
 * @author Adam
 *
 */
public abstract class StructureManager implements PlayableManager, StructureUpdatable 
{
	private PlayableMapping playableMapping = PlayableMapping.getPlayableMapping();
	private Player player;
	private ResourceManager resourceManager;
	private String type;
	
	public StructureManager(Player player, ResourceManager rm, String type)
	{
		this.player = player;
		this.resourceManager = rm;
		this.type = type;
	}
	
	public String getType()
	{
		return type;
	}
	
	public Player getPlayer()
	{
		return player;
	}
	
	public PlayableMapping getPlayableMapping()
	{
		return playableMapping;
	}
	
	public abstract void createNewStructure(GameTile tile, Worker[] workers);

	public void addStructureToMap(GameTile tile, Structure s)
	{
		playableMapping.addStructure(tile, s);
	}

	public void removeFromMap(Structure s)
	{
		playableMapping.removeStructure(s);
	}
	
	public int grabFood(int amount)
	{
		return resourceManager.takeFood(amount);
	}
	
	public int grabOre(int amount)
	{
		return resourceManager.takeFood(amount);
	}
	
	public int grabEnergy(int amount)
	{
		return resourceManager.takeFood(amount);
	}
	
	public abstract List<Structure> getAllStructures();
}
